import React, { Component } from 'react';
import DomHelper from './domHelper';

class Scene extends Component {
    constructor(props) {
        super(props);
        this.state = {
            loaded: false,
        };
    }

    componentDidMount() {
        this.scene = new THREE.Scene();
        DomHelper.scene = this.scene;
        DomHelper.update();
        this.setState({
            loaded: true,
        });
    }

    componentWillUnmount() {
        DomHelper.scene.remove();
    }

    render() {
        return (
            <div className="threed-scene">
                {this.state.loaded ? this.props.children : ''} 
            </div>
        )
    }
}

export default Scene;
